package com.deng.etl.impl;

import java.sql.Connection;
import java.util.Date;

import com.deng.common.SQLHelper;
import com.deng.etl.common.EtlAuto;
import com.deng.util.DateTools;

public class WorkLoadMoveToBack extends SQLHelper {

	public static String stat_time;
	public static int dispense_id;
	public int workLoatMoveToBackByOrganizationId(String stat_time,int dispense_id){
		try{
			WorkLoadMoveToBack.stat_time = stat_time;
			WorkLoadMoveToBack.dispense_id = dispense_id;
			new Thread(){
				@Override
				public void run() {
					try{
						Connection conn = new EtlAuto().getTargetConn();
				        String dt = DateTools.dtsWithTimeS0(new Date());
						String sql = "insert into t_org_organization_item_count_month_backup" +
								"	(backup_time,stat_time,create_time,org_order_organization_id," +
								"	org_order_organization_name,org_order_doctor_id,org_order_doctor_name," +
								"	org_operate_organization_id,org_operate_organization_name,org_operate_doctor_id," +
								"	org_operate_doctor_name,org_work_group_id,org_work_group_name,org_fee_type_id," +
								"	org_fee_type_name,org_item_id,org_item_name,org_item_count,id,sjly,fee)" +
								"	select '"+dt+"',stat_time,create_time,org_order_organization_id," +
								"	org_order_organization_name,org_order_doctor_id,org_order_doctor_name," +
								"	org_operate_organization_id,org_operate_organization_name,org_operate_doctor_id," +
								"	org_operate_doctor_name,org_work_group_id,org_work_group_name,org_fee_type_id," +
								"	org_fee_type_name,org_item_id,org_item_name,org_item_count,id,sjly,fee" +
								"	from t_org_organization_item_count_month" +
								"	where stat_time = '"+WorkLoadMoveToBack.stat_time+"'" +
								"	and org_operate_organization_id in (select original_id " +
								"	from t_sys_stat_department_vs_original_department " +
								"	where stat_id = "+WorkLoadMoveToBack.dispense_id+")";
						System.out.println("备份数据抽取：  ");
						updateData(conn, sql);
					}catch(Exception ex){
						ex.printStackTrace();
					}									
				}
			}.start();
			
		}catch(Exception ex){
			ex.printStackTrace();
		}
		return 0;
	}
}
